<template>
  <view class="my-search-container" :style="{backgroundColor: bgcolor}">
    <view class="my-search-box" :style="{borderRadius: radius+'px'}" @click="searchBoxHandler">
      <uni-icons type="search" size="18"></uni-icons>
      <text class="my-search-text">搜索</text>
    </view>
  </view>
</template>

<script>
  export default {
    name: "my-search",
    data() {
      return {

      };
    },
    props: {
      // 背景色
      bgcolor: {
        type: String,
        default: '#c00000'
      },
      radius: {
        type: Number,
        default: 18
      }
    },
    methods: {
      // 子组件输入框事件处理函数
      searchBoxHandler() {
        // 调用父组件绑定的事件处理函数
        this.$emit('click')
      }
    }
  }
</script>

<style lang="scss">
  .my-search-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
    background-color: #c00000;
    padding: 0 10px;

    .my-search-box {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 36px;
      width: 100%;
      border-radius: 18px;
      background-color: #ffffff;

      .my-search-text {
        margin-left: 6px;
      }
    }
  }
</style>
